<!DOCTYPE html>
<html  lang="en">
<head>
    <meta charset="utf-8">
<title>Category: blog_back_new - noback</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />



    <meta property="og:type" content="website">
<meta property="og:title" content="noback">
<meta property="og:url" content="http://alpaca-h.gitee.io/categories/blog-back-new/page/4/index.html">
<meta property="og:site_name" content="noback">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://alpaca-h.gitee.io/images/og_image.png">
<meta property="article:author" content="Alpaca">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://alpaca-h.gitee.io/images/og_image.png">







<link rel="icon" href="/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/androidstudio.css">


    
    
    
    <style>body>.footer,body>.navbar,body>.section{opacity:0}</style>
    

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
    

    
    

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">


    
    
    
    

<link rel="stylesheet" href="/css/back-to-top.css">


    
    

    
    
    
    

    
    
<link rel="stylesheet" href="/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

    
    
    

    
    
    
        <script async="" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    

    


<link rel="stylesheet" href="/css/style.css">
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="noback" type="application/atom+xml">
</head>
<body class="is-3-column">
    <nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/">
            
                <img src="/images/logo.svg" alt="noback" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item"
                href="/">Home</a>
                
                <a class="navbar-item"
                href="/archives/">Archives</a>
                
                <a class="navbar-item"
                href="/categories/">Categories</a>
                
                <a class="navbar-item"
                href="/tags/">Tags</a>
                
                <a class="navbar-item"
                href="/about/">About</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    
                    <a class="navbar-item" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                
                <a class="navbar-item search" title="Search" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-6-widescreen has-order-2 column-main"><div class="card">
    <div class="card-content">
        <nav class="breadcrumb" aria-label="breadcrumbs">
        <ul>
            <li><a href="/categories">Categories</a></li>
            
            <li class="is-active"><a href="#" aria-current="page">blog_back_new</a></li>
        </ul>
        </nav>
    </div>
</div>

    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/29/blog_back_new/Rust/rust%E5%9F%BA%E7%A1%80/rust%E7%BB%93%E6%9E%84%E4%BD%93/"><i class="fas fa-angle-double-right"></i>rust结构体</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-29T03:17:50.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-29</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-30T01:46:15.774Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-30</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Rust/">Rust</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    3 minutes read (About 414 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="定义实例化结构体"><a href="#定义实例化结构体" class="headerlink" title="定义实例化结构体"></a>定义实例化结构体</h2><p>定义结构体，需要使用 struct 关键字并为整个结构体提供一个名字。结构体的名字需要描述它所组合的数据的意义.在结构体中需要有相应的属性和属性对应的类型</p>
<pre><code class="rust">fn main() {

// 创建实例模版
struct User {
    username: String,
    email: String,
    sign_in_count: u64,
    active: bool,
}

// 实例化不可变模型
let user1 = User {
    email: String::from(&quot;someone@example.com&quot;),
    username: String::from(&quot;someusername123&quot;),
    active: true,
    sign_in_count: 1,
};
}
// 实例化可变模型
let  mut user2 = User {
    email: String::from(&quot;someone@example.com&quot;),
    username: String::from(&quot;someusername123&quot;),
    active: true,
    sign_in_count: 1,
};
}

// 调用与修改
println!(&quot;{}&quot;, user2.email)
user2.email = String::from(&quot;other@example.com&quot;)</code></pre>
<h3 id="使用函数来返回并创建实例化模型"><a href="#使用函数来返回并创建实例化模型" class="headerlink" title="使用函数来返回并创建实例化模型"></a>使用函数来返回并创建实例化模型</h3><pre><code class="rust">fn main() {
    let user = return_struct(String::from(&quot;xx&quot;),2);
    println!(&quot;{}&quot;,user.name);
}

struct User {
    name: String,
    age: i32,
    active: bool,
    sigin_in_count: i32,
}

fn return_struct(name: String,age: i32 ) -&gt; User {
    User {
        //同名字段
        //1. name: name,
        //2. name,
        name,
        age,
        active: true,
        sigin_in_count: 1,
    }
}
</code></pre>
<h3 id="实例更新"><a href="#实例更新" class="headerlink" title="实例更新"></a>实例更新</h3><pre><code class="rust">let user2 = User {
    email: String::from(&quot;another@example.com&quot;),
    username: String::from(&quot;anotherusername567&quot;),
    ..user1
}; </code></pre>
<h3 id="元组结构体"><a href="#元组结构体" class="headerlink" title="元组结构体"></a>元组结构体</h3><p>没有字段名 只有字段类型</p>
<pre><code class="rust">fn main() {
struct Color(i32, i32, i32);
struct Point(i32, i32, i32);

let black = Color(0, 0, 0);
let origin = Point(0, 0, 0);
}</code></pre>
<h3 id="方法语法"><a href="#方法语法" class="headerlink" title="方法语法"></a>方法语法</h3><p>方法语法同函数类似，但是方法实在结构体的上下文中被定义的，并且他们的第一个参数是self，它代表了调用该方法的结构体实例</p>
<p>我们将某个实例能做的所有事情一起放在impl(implementation)中</p>
<pre><code class="rust">struct Rectangle{
        width: u32,
        height: u32,
}
// 必须同名
impl Rectangle{
    fn area(&amp;self) -&gt; u32{
        self.width * self.height
    }
}
fn main() {
    let rect1 = Rectangle{width: 30,height: 50};

    println!(
        &quot;the area is {}&quot;,rect1.area()
    );
}
</code></pre>
<p>其中self表示调用该方法的结构体实例</p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/28/blog_back_new/Rust/rust%E5%9F%BA%E7%A1%80/61-rust%E6%89%80%E6%9C%89%E6%9D%83/"><i class="fas fa-angle-double-right"></i>Rust概念-所有权</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-28T13:56:19.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-28</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-29T03:16:04.707Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-29</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Rust/">Rust</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    10 minutes read (About 1550 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="Rust概念-所有权"><a href="#Rust概念-所有权" class="headerlink" title="Rust概念-所有权"></a>Rust概念-所有权</h2><h3 id="变量类型"><a href="#变量类型" class="headerlink" title="变量类型"></a>变量类型</h3><p>可以看一下这两篇文章<br><a href="https://learning-rust.github.io/docs/a6.variable_bindings,constants_and_statics.html" target="_blank" rel="noopener">https://learning-rust.github.io/docs/a6.variable_bindings,constants_and_statics.html</a><br><a href="http://wiki.jikexueyuan.com/project/rust/primitive-types.html" target="_blank" rel="noopener">http://wiki.jikexueyuan.com/project/rust/primitive-types.html</a></p>
<p>在rust中变量模式是不可变的，因此我们叫做变量绑定，为了使他们可变，使用mut关键字即可<br>rust是一种静态类型的语言；它在编译时检查数据类型。并不需要在声明变量绑定时指定一个具体的数据类型。编译器会检查使用情况并为其设置更好的数据类型。<br>但是对于 <font color='red'>常量和静态变量</font>，必须注释type。类型在冒号（:)之r</p>
<h3 id="变量绑定"><a href="#变量绑定" class="headerlink" title="变量绑定"></a>变量绑定</h3><pre><code class="rust">// 变量绑定
let a = true;
let b: bool = true; 
// 以上可以声明具体的数据类型，也可以不指定

let (x,y) = (1,2);

let mut z = 5;
z = 6;

// 常数  必须指定
const N: i32 = 5;

// 静态变量
static N: i32 = 6;</code></pre>
<h3 id="所有权"><a href="#所有权" class="headerlink" title="所有权"></a>所有权</h3><p>在rust中，一共分为两种数据类型</p>
<ol>
<li>基本数据类型： 如：bool（布尔），char（字符）,integer（整数）,floating（浮点）,arrays（数组），tuples(元组)，slice(切片),字符串（str），函数指针(functions)</li>
<li>非基本数据类型 也就是引用类型</li>
</ol>
<p>在rust中，对于所有权一共有两种动作状态  移动和copy</p>
<ul>
<li>复制<br>当将a赋值给b的时候，首先rust会对原来a的元数据进行复制，并将复制的数据赋值给b，并把a的所有权状态 设置为“已复制（ copied ）”状态。</li>
<li>移动<br>当将a赋值给b的时候，rust会把原来对a的原数据的所有权移动给b，并把a的所有权状态 设置为“已移动（ moved ）”状态。<pre><code class="rust">let x = 5;
let y = x;
// 基本数据类型 只发生了copied
let x = String::from(&quot;hello world&quot;);
let y = x;
// 引用数据类型，发生了moved</code></pre>
<img src="http://img.noback.top/2019-12-28-23-30-18.png" alt="2019-12-28-23-30-18"><br>引用类型在存储到堆中时，会指定三个部分 分别时指针，长度和容量，并且指针指向堆上存放内存的内存地址<br>长度表示 String 的内容当前使用了多少字节的内存。容量是 String 从操作系统总共获取了多少字节的内存。长度与容量的区别是很重要的，</li>
</ul>
<h3 id="复制行为"><a href="#复制行为" class="headerlink" title="复制行为"></a>复制行为</h3><p><img src="http://img.noback.top/2019-12-28-23-32-47.png" alt="2019-12-28-23-32-47"><br>复制行为中，拷贝了一整份内容，包括指针长度和容量，于是他们共用同一个内存，而不是分别指向相等的两个内存<br><font color='red'>二次释放错误</font><br>当变量离开作用域的使用,Rust自动调用drop函数并清理变量的堆内存，于是当出现复制行为的时候，他们执行的内存地址是相同的，当s1离开后，s2执行的内存地址无。当s1离开后，s2执行的内存地址无，这个叫做二次释放的错误，也是之前提到过的内存安全性 bug 之一。两次释放（相同）内存会导致内存污染，它可能会导致潜在的安全漏洞。<br><font color='blue'>但是我在代码中试了一下，没有报错。。。</font></p>
<pre><code class="rust">fn main() {
     let x = 1;
     let y = x;
     println!(&quot;Hello, world!{}&quot;,y);
     println!(&quot;{}&quot;,x)
} 
// input
Hello, world!1
1</code></pre>
<h3 id="移动行为"><a href="#移动行为" class="headerlink" title="移动行为"></a>移动行为</h3><p><img src="http://img.noback.top/2019-12-28-23-43-58.png" alt="2019-12-28-23-43-58"><br>如果将原变量指针移向另外一个变量指针，原变量指针失效。当你再次调用s1变量时，由于指针的失去，没有指向存储数据的内存地址，报错无效引用</p>
<pre><code class="rust">fn main() {
    let x = String::from(&quot;hello&quot;); // 这个是引用类型。数据在堆上面
    let y = x;
    println!(&quot;Hello, world!{}&quot;,y);
    println!(&quot;{}&quot;,x)
}

// input
error[E0382]: borrow of moved value: `x`
 --&gt; src/main.rs:5:19
  |
2 |     let x = String::from(&quot;hello&quot;);
  |         - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
3 |     let y = x;
  |             - value moved here
4 |     println!(&quot;Hello, world!{}&quot;,y);
5 |     println!(&quot;{}&quot;,x)
  |                   ^ value borrowed here after move

error: aborting due to previous error

For more information about this error, try `rustc --explain E0382`.
error: could not compile `xx`.

To learn more, run the command again with --verbose.
// 指针报错
指针已经被move</code></pre>
<h3 id="克隆行为"><a href="#克隆行为" class="headerlink" title="克隆行为"></a>克隆行为</h3><p>对于基础类型来说，变量的数据交互形式是复制<br>对于引用类型来说，变量的数据交互形式无法复制，只能移动。但是如果我们需要使用到复制堆上的数据，可以使用clone的通用函数</p>
<pre><code class="rust">fn main() {
    let x = String::from(&quot;hello&quot;); // 这个是引用类型。数据在堆上面
    let y = x.clone();
    println!(&quot;Hello, world!{}&quot;,y);
    println!(&quot;{}&quot;,x)
} </code></pre>
<h2 id="引用和借用"><a href="#引用和借用" class="headerlink" title="引用和借用"></a>引用和借用</h2><h3 id="不可变引用"><a href="#不可变引用" class="headerlink" title="不可变引用"></a>不可变引用</h3><p>跳过所有权，引用对象数据，这里就要用到rust中的引用关键字&amp;<br>&amp;关键字作用是创建了一条指向某一对象的引用，再由引用对象指向数据错在内存地址<br>当引用本身&amp;s1离开作用域后，调用drop函数，指向s1对象的指针被丢弃<br>同时，rust的引用本身也是不可变的，</p>
<pre><code class="rust">fn main() {
    let s1 = String::from(&quot;hello&quot;);

    let len = calculate_length(&amp;s1);

    println!(&quot;The length of &#39;{}&#39; is {}.&quot;, s1, len);
}

//参数类型需要引用类型
fn calculate_length(s: &amp;String) -&gt; usize {
    s.len()
}</code></pre>
<p><img src="http://img.noback.top/2019-12-29-09-38-03.png" alt="2019-12-29-09-38-03"><br>以上 &amp;s1的过程称为引用，获取因果那个作为函数参数称为借用</p>
<h3 id="可变引用"><a href="#可变引用" class="headerlink" title="可变引用"></a>可变引用</h3><p>可变引用同不可变类似，但要保证<br>被引用类型为可变类型<br>引用为可变<br>函数参数为可变引用</p>
<pre><code class="rust">fn main() {
    let mut s = String::from(&quot;hello&quot;);
    change(&amp;mut s);
}
fn change(some_string: &amp;mut String) {
    some_string.push_str(&quot;, world&quot;);
}</code></pre>
<p><font color='blue'>在特定作用域中的特定数据有且只有一个可变引用。这些代码会失败;但可以有多个不可变引用,并且不可变引用和可变引用不能同时存在，可以在其中一个小时后再调用</font><br>解决</p>
<pre><code class="rust">let mst s = String::from(&quot;hello&quot;)
{
  let r1 = &amp;mut s;
} 
let r2 = &amp;mut s;</code></pre>
<h2 id="slice-切片"><a href="#slice-切片" class="headerlink" title="slice 切片"></a>slice 切片</h2><pre><code class="rust">let s = String::from(&quot;hello world&quot;) 
let hello = &amp;s[..5];
// let hello = &amp;s[0..5];
let world = &amp;s[6..11];
// let world = &amp;s[6..len];

let helloworld = &amp;s[..];
let helloworld = &amp;s[0..len];
</code></pre>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/27/blog_back_new/Python/python%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%951/"><i class="fas fa-angle-double-right"></i>Python常用方法</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-27T09:36:31.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-27</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-04T00:18:01.299Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-04</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Python/">Python</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    5 minutes read (About 685 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="python-常用方法"><a href="#python-常用方法" class="headerlink" title="python 常用方法"></a>python 常用方法</h1><h2 id="保留小数"><a href="#保留小数" class="headerlink" title="保留小数"></a>保留小数</h2><p>使用字符串格式化</p>
<pre><code class="python">a = 11.234
print(&quot;%.2f&quot;%a) </code></pre>
<p>使用round内置函数</p>
<pre><code class="python">a = 11.234
a = round(a,2)
print(a) </code></pre>
<p>使用decimal模块</p>
<pre><code class="python">from decimal import Decimal
a = 12.345
Decimal(a).quantize(Decimal(&quot;0.00&quot;)) </code></pre>
<h2 id="列表"><a href="#列表" class="headerlink" title="列表"></a>列表</h2><h3 id="列表合并"><a href="#列表合并" class="headerlink" title="列表合并"></a>列表合并</h3><pre><code class="python"># 使用+号操作
list1 = [1,2,3,4,5]
list2 = [&quot;z&quot;,&quot;xx&quot;,] 
list3 = list1+list2
# 使用extend
list4.extend(list1)
# 使用切片
list4[len(11):len(11)] = list5</code></pre>
<h2 id="os模块"><a href="#os模块" class="headerlink" title="os模块"></a>os模块</h2><h3 id="Python获取指定文件夹下的文件名"><a href="#Python获取指定文件夹下的文件名" class="headerlink" title="Python获取指定文件夹下的文件名"></a>Python获取指定文件夹下的文件名</h3><p><font color='red'>模块os.walk可以遍历文件夹下的所有文件</font></p>
<pre><code class="python">os.walk(top, topdown=Ture, οnerrοr=None, followlinks=False)
# return  (dirpath dirnames filenames)</code></pre>
<ul>
<li>dirpath: string 代表目录的路径</li>
<li>dirnames list 包含了当前dirpath路径下所有的子目录名字（不包含目录路径）</li>
<li>filenames：list，包含了当前dirpath路径下所有的非目录子文件的名字（不包含目录路径）。<pre><code class="python">import os
</code></pre>
</li>
</ul>
<p>def file_name(file_dir):<br>    for root, dirs, files in os.walk(file_dir):<br>        print(root) #当前目录路径<br>        print(dirs) #当前路径下所有子目录<br>        print(files) #当前路径下所有非目录子文件<br>        for file in files:<br>            # os.path.splitext # 对文件名进行切割成数组<br>            if os.path.splitext(file)[1] == “.jpeg”:<br>              print(file)<br>            else:<br>              pass</p>
<pre><code>
&lt;font color=&#39;red&#39;&gt;模块os.listdir()可以得到当前路径下的文件名，不包括子目录中的文件&lt;/font&gt;

```python
import os
# 遍历获取所有文件
def listdir(path, list_name):
    for file in os.listdir(path):
        file_path = os.path.join(path, file)
        # os.path.isdir(file) #判断文件是否为文件夹
        if os.path.isdir(file_path):
            listdir(file_path, list_name)
        elif os.path.splitext(file_path)[1]==&#39;.jpeg&#39;:
            list_name.append(file_path)</code></pre><h3 id="判断文件类型"><a href="#判断文件类型" class="headerlink" title="判断文件类型"></a>判断文件类型</h3><pre><code class="python">os.path.isdir(path) # 是否为文件夹
os.path.isfile(path) # 是否为文件</code></pre>
<h2 id="文件操作"><a href="#文件操作" class="headerlink" title="文件操作"></a>文件操作</h2><p>mode选项<br>r 读模式，只能读 文件不存在报错，<br>w 写模式，只能写 文件不存在则创建，<br>以上存在存在则清空在打开</p>
<p>rb 二进制读模式 只能读  文件不存在报错<br>wb 二进制写模式 只能写  文件不存在则创建，<br>以上存在则清空再打开<br>有二进制内容 写入则需要encode(“utf-8”)</p>
<p>rb+ 二进制读模式 可读可写 文件不存在报错<br>wb+ 二进制写模式 可读可写 文件不存在则创建，<br>以上存在则清空再打开</p>
<p>a 追加写模式，文件存在则追加写入<br>a+ 追加读写方式<br>以上存在则追加写入</p>
<p>默认进入为文件末尾<br>f.seek(0) 设置读写位置为开头<br>f.truncate(0) 将文章字节阶段为0</p>
<h3 id="文件头部写如文件"><a href="#文件头部写如文件" class="headerlink" title="文件头部写如文件"></a>文件头部写如文件</h3><pre><code class="bash">with open(path, &quot;r+&quot;) as f:
     old = f.read()
     f.seek(0)
     f.write(data)
     f.write(old)</code></pre>
<p>或者</p>
<pre><code class="bash">with open(path,&quot;a&quot;) as f:
      f.seek(0)
      old = f.read()
      # 全部删除
      f.truncate(0)
      f.write(&quot;---&quot;)
      f.write(&quot;tags: xxx&quot;)
      f.write(&quot;---&quot;)
      f.close()</code></pre>
<h2 id="python应"><a href="#python应" class="headerlink" title="python应"></a>python应</h2>
        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/27/blog_back_new/Python/python%E6%8A%A5%E9%94%99%E6%80%BB%E7%BB%93/"><i class="fas fa-angle-double-right"></i>Python报错总结</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-27T09:36:10.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-27</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-27T14:28:59.239Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-27</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Python/">Python</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    a few seconds read (About 60 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="Python报错总结"><a href="#Python报错总结" class="headerlink" title="Python报错总结"></a>Python报错总结</h1><h2 id="Non-ASCII"><a href="#Non-ASCII" class="headerlink" title="Non-ASCII"></a>Non-ASCII</h2><p>python出现SyntaxError: Non-ASCII character ‘\xe6’ in file 打印日期.py on line 1, but no encoding declared;</p>
<p><font color='red'>解决方法</font><br>在文件头部添加如下两行注释码：</p>
<pre><code class="python">#!/usr/bin/python
# -*- coding: &lt;encoding name&gt; -*- 例如，可添加# -*- coding: utf-8 -*-</code></pre>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/27/blog_back_new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%B7%B1%E6%8B%B7%E8%B4%9D%E4%B8%8E%E6%B5%85%E6%8B%B7%E8%B4%9D/"><i class="fas fa-angle-double-right"></i>深拷贝与浅拷贝</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-27T09:33:42.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-27</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-28T15:02:41.614Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-28</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">数据结构</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    4 minutes read (About 598 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="数据类型"><a href="#数据类型" class="headerlink" title="数据类型"></a>数据类型</h1><p>数据分为</p>
<ul>
<li><p>基本数据类型(String, Number, Boolean, Null, Undefined，Symbol)</p>
</li>
<li><p>对象数据类型。</p>
</li>
<li><p>基本数据类型的特点: 直接存储在栈(stack)中的数据</p>
</li>
<li><p>引用数据类型的特点：存储的是该对象在栈中引用，真实的数据存放在堆内存里<br>引用数据类型在栈中存储了指针，该指针指向堆中该实体的起始地址。当解释器寻找引用值时，会首先检索其在栈中的地址，取得地址后从堆中获得实体。</p>
</li>
</ul>
<p>[图]</p>
<h3 id="深拷贝和浅拷贝"><a href="#深拷贝和浅拷贝" class="headerlink" title="深拷贝和浅拷贝"></a>深拷贝和浅拷贝</h3><p>深拷贝和浅拷贝是只针对Object和Array这样的引用数据类型的。<br>浅拷贝只复制指向某个对象的指针，而不复制对象本身，新旧对象还是共享同一块内存。但深拷贝会另外创造一个一模一样的对象，新对象跟原对象不共享内存，修改新对象不会改到原对象。<br><img src="https://user-gold-cdn.xitu.io/2018/7/29/164e6856d76ff161?imageslim" alt="图片"><br><font color='blue'>是和Linux中的软硬链接有关系吗</font></p>
<h3 id="赋值和浅拷贝的区别"><a href="#赋值和浅拷贝的区别" class="headerlink" title="赋值和浅拷贝的区别"></a>赋值和浅拷贝的区别</h3><ul>
<li>当我们把一个对象赋值给一个新的变量时，赋的其实是该对象的在栈中的地址，而不是堆中的数据。也就是两个对象指向的是同一个存储空间，无论哪个对象发生改变，其实都是改变的存储空间的内容，因此，两个对象是联动的。</li>
<li>浅拷贝是按位拷贝对象，它会创建一个新对象，这个对象有着原始对象属性值的一份精确拷贝。如果属性是基本类型，拷贝的就是基本类型的值；如果属性是内存地址（引用类型），拷贝的就是内存地址 ，因此如果其中一个对象改变了这个地址，就会影响到另一个对象。即默认拷贝构造函数只是对对象进行浅拷贝复制(逐个成员依次拷贝)，即只复制对象空间而不复制资源。</li>
</ul>
<p>浅拷贝与深拷贝</p>
<p><a href="https://www.runoob.com/w3cnote/python-understanding-dict-copy-shallow-or-deep.html" target="_blank" rel="noopener">https://www.runoob.com/w3cnote/python-understanding-dict-copy-shallow-or-deep.html</a><br><a href="https://juejin.im/post/5b5dcf8351882519790c9a2e#heading-7" target="_blank" rel="noopener">https://juejin.im/post/5b5dcf8351882519790c9a2e#heading-7</a></p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/26/blog_back_new/Rust/rust%E5%9F%BA%E7%A1%80/60-rust%E5%9F%BA%E7%A1%80/"><i class="fas fa-angle-double-right"></i>rust基础2</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-26T04:27:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-26</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-26T04:58:48.003Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-26</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Rust/">Rust</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    6 minutes read (About 856 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="rust基础"><a href="#rust基础" class="headerlink" title="rust基础"></a>rust基础</h1><h2 id="变量常量"><a href="#变量常量" class="headerlink" title="变量常量"></a>变量常量</h2><p>rust采用多种变量的定义形式，同时在定义的同时区分了变量与常量的区别 </p>
<pre><code class="bash">定义变量使用let xx=xx  # 默认immutable
定义可变变量 let mut xx=xx  # mut 可变
定义常量 const xx: u32 = 10000 # 常量定义 名为xx  类型为int32 值为10000</code></pre>
<p>其中常量默认不变</p>
<pre><code class="go">fn main() {
    let x = 5;
    println!(&quot;The value of x is:{}&quot;,x);
    let mut y = 6;
    println!(&quot;The mut value of y is:{}&quot;,y);

    //修改不可变量x  报错
    //x = 7
    //println!(&quot;i upadte the x value 5 to {}&quot;,x)

    y = 10;
    println!(&quot;i update the y value 6 to {}&quot;,y);

    //定义常量,他的名字是MAX_POINTS
    const MAX_POINTS: u32 = 100_000;
    println!(&quot;is constants value  MAX_POINTS: {}&quot;,MAX_POINTS);

    //变量迭代 隐藏
    //对变量的隐藏，也就是不断的对x进行隐藏
    //虽然变量x是不可变的immutable 但是重复使用let可以多次进行隐藏，生成之后的仍就是immutable
    let q = 5;
    let q = q + 5;
    let q = q + 10;
    println!(&quot;q:{}&quot;,q)

    //
    let spaces = &quot;    &quot;;
    let spaces_line = spaces.len();
    println!(&quot;spance_lines_number:{}&quot;,spaces_line)

    //
    let mut numbers = &quot;   &quot;;
    numbers = numbers.len();
    println!(&quot;{}&quot;,numbers)
}</code></pre>
<p><font color='red'>可变量mut 和隐藏shadowing有什么区别?</font><br>mut 与隐藏的另一个区别是，当再次使用 let 时，实际上创建了一个新变量，我们可以改变值的类型，并且复用这个名字。例如，假设程序请求用户输入空格字符来说明希望在文本之间显示多少个空格，然而我们真正需要的是将输入存储成数字（多少个空格）</p>
<h2 id="datatype数据类型"><a href="#datatype数据类型" class="headerlink" title="datatype数据类型"></a>datatype数据类型</h2><p>rust是静态类型语言(statically typed)<br>也就是说在编译时就必须知道所有变量的类型。</p>
<h3 id="整型"><a href="#整型" class="headerlink" title="整型"></a>整型</h3><pre><code class="bash"></code></pre>
<pre><code class="bash">度    有符号    无符号
8-bit    i8    u8
16-bit    i16    u16
32-bit    i32    u32
64-bit    i64    u64
128-bit    i128    u128
arch    isize    usize</code></pre>
<p>有符号和无符号代表数字能否为负值，有符号数以补码形式（two’s complement representation）[<a href="https://kaisery.github.io/trpl-zh-cn/ch03-02-data-types.html]" target="_blank" rel="noopener">https://kaisery.github.io/trpl-zh-cn/ch03-02-data-types.html]</a> 存储。</p>
<h3 id="浮点型"><a href="#浮点型" class="headerlink" title="浮点型"></a>浮点型</h3><p>它们是带小数点的数字。Rust 的浮点数类型是 f32 和 f64，分别占 32 位和 64 位。默认类型是 f64，因为在现代 CPU 中，它与 f32 速度几乎一样，不过精度更高。</p>
<pre><code class="rust">fn main(){
    let x = 2.0; //f64
    let y: f32 = 3.0; //f32
} </code></pre>
<h3 id="数值运算"><a href="#数值运算" class="headerlink" title="数值运算"></a>数值运算</h3><pre><code class="rust">fn main(){
    let sum = 5 + 32;
    let difference = 95.5 - 4.3;
    let product = 4 * 30;
    let quotient = 56.7 / 32.2;
    let remainder = 43 % 5;
}</code></pre>
<h3 id="布尔型"><a href="#布尔型" class="headerlink" title="布尔型"></a>布尔型</h3><pre><code class="rust">fn main(){
    let t = true ;
    let f: boole = false; // 显式指定类型注解
} </code></pre>
<h3 id="字符型"><a href="#字符型" class="headerlink" title="字符型"></a>字符型</h3><p>char使用单引号 string使用双引号</p>
<pre><code class="bash">fn main() {
    let c = &#39;z&#39;;
    let z = &#39;ℤ&#39;;
    let heart_eyed_cat = &#39;😻&#39;;
} </code></pre>
<h3 id="元组类型"><a href="#元组类型" class="headerlink" title="元组类型"></a>元组类型</h3><p>元组是一个将多个其他类型的值组合进一个复合类型的主要方式。元组长度固定：一旦声明，其长度不会增大或缩小。</p>
<pre><code class="rust">fn main() {
    let tup: (i32, f64, u8) = (500, 6.4, 1);
} </code></pre>
<pre><code class="rust">fn main() {
    let tup = (500, 6.4, 1);

    let (x, y, z) = tup;

    println!(&quot;The value of y is: {}&quot;, y);
} </code></pre>
<p>使用解构拆分元祖tup 对应元祖值</p>
<pre><code class="rust">fn main() {
    let x: (i32, f64, u8) = (500, 6.4, 1);

    let five_hundred = x.0;

    let six_point_four = x.1;

    let one = x.2;
} </code></pre>
<h3 id="数组类型"><a href="#数组类型" class="headerlink" title="数组类型"></a>数组类型</h3><pre><code class="bash">fn main() {
    # 定义方法1
    let a = [1, 2, 3, 4, 5];
    # 定义方法2
    let a: [i32; 5] = [1, 2, 3, 4, 5];
    # 定义方法3
    let a = [3;5] # =&gt; [3,3,3,3,3]
} </code></pre>
<pre><code class="bash">fn main() {
    let a = [1, 2, 3, 4, 5];

    let first = a[0];
    let second = a[1];
}
</code></pre>
<h2 id="函数方法"><a href="#函数方法" class="headerlink" title="函数方法"></a>函数方法</h2><pre><code class="bash">fn main() {
    println!(&quot;Hello, world!&quot;);

    another_function();
}

fn another_function() {
    println!(&quot;Another function.&quot;);
} 

# 加参数
fn main() {
    another_function(5);
}

fn another_function(x: i32) {
    println!(&quot;The value of x is: {}&quot;, x);
}

# 多参数
fn main() {
    another_function(5, 6);
}

fn another_function(x: i32, y: i32) {
    println!(&quot;The value of x is: {}&quot;, x);
    println!(&quot;The value of y is: {}&quot;, y);
}</code></pre>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/26/blog_back_new/Rust/rust%E5%9F%BA%E7%A1%80/1-start/"><i class="fas fa-angle-double-right"></i>Rust基础</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-26T04:27:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-26</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-26T04:58:48.003Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-26</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Rust/">Rust</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    3 minutes read (About 458 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="Install"><a href="#Install" class="headerlink" title="Install"></a>Install</h1><p>url <a href="https://www.rust-lang.org/zh-CN/tools/install" target="_blank" rel="noopener">https://www.rust-lang.org/zh-CN/tools/install</a></p>
<pre><code class="bash">curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://sh.rustup.rs | sh</code></pre>
<p>while you input enter ，will install rust default</p>
<p>上面这条命令会安装一些内容，比如  cargo  rustup<br>如果你想要使用他们，需要将他们添加到环境变量中</p>
<pre><code class="bash"># 方法1
source $HOME/.cargo/env

# 方法2
export  PATH=&quot;$HOME/.cargo/bin:$PATH&quot; 

# 其实env里面写的就是方法2
# 查看是否安装完成
rustc --version
rustc 1.39.0 (4560ea788 2019-11-04)</code></pre>
<h1 id="update"><a href="#update" class="headerlink" title="update"></a>update</h1><p>更新版本, rustup用来管理rust的版本,rust每6个礼拜会进行一次版本迭代，使用rustup update更新版本</p>
<pre><code class="bash">rustup update </code></pre>
<h1 id="cargo工具"><a href="#cargo工具" class="headerlink" title="cargo工具"></a>cargo工具</h1><p>Cargo：Rust 的构建工具和包管理器</p>
<pre><code class="bash">cargo build #构建项目
cargo run # 构建并运行项目
cargo test # 测试项目
cargo doc # 为项目构建文档
cargo publish # 将库发布到cartes.io 
cargo new xxproject # 创建xxproject项目


# cargo  开发者社区</code></pre>
<h2 id="cargo-使用"><a href="#cargo-使用" class="headerlink" title="cargo 使用"></a>cargo 使用</h2><pre><code class="bash">cargo new helloworld # 创建一个项目helloworld 

# 生成如下文件
[root@dev rustttt]#  tree .
.
└── helloworld
    ├── Cargo.toml
    └── src
        └── main.rs</code></pre>
<ul>
<li>Cargo.toml中包含了编译你项目时所需要的内容清单</li>
<li>src/main.rs 中包含了主程序</li>
</ul>
<p>使用cargo build 构建项目,编译完成之后，会在生成一个编译后的可执行文件，执行他们</p>
<pre><code class="bash">[root@dev helloworld]# ./target/debug/helloworld
Hello, world! </code></pre>
<p>使用cargo run 构建项目并运行。</p>
<pre><code class="bash">[root@dev helloworld]# cargo run
   Compiling helloworld v0.1.0 (/root/rustttt/helloworld)
    Finished dev [unoptimized + debuginfo] target(s) in 0.51s
     Running `target/debug/helloworld`
Hello, world! </code></pre>
<p><font color='red'>具体是使用文档</font><br><font color='red'><a href="https://doc.rust-lang.org/cargo/guide/index.html" target="_blank" rel="noopener">https://doc.rust-lang.org/cargo/guide/index.html</a></font></p>
<h2 id="编译rust文件-rustc"><a href="#编译rust文件-rustc" class="headerlink" title="编译rust文件  rustc"></a>编译rust文件  rustc</h2><pre><code class="bash"># 使用cargo build创建helloworld目录
cargo build helloworld
cd helloworld/src/
# 编译文件
rustc main.rs 
./main
# 输出内容
hello wolrd</code></pre>
<h2 id="other"><a href="#other" class="headerlink" title="other"></a>other</h2><p>不下载环境，直接测试代码<br><a href="https://play.rust-lang.org" target="_blank" rel="noopener">https://play.rust-lang.org</a><br>Rust官方文档<br><a href="https://www.rust-lang.org/zh-CN/tools/install" target="_blank" rel="noopener">https://www.rust-lang.org/zh-CN/tools/install</a></p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/26/blog_back_new/Rust/rust%E5%9F%BA%E7%A1%80/2-rust%E7%8C%9C%E8%B0%9C%E6%B8%B8%E6%88%8F/"><i class="fas fa-angle-double-right"></i>rust猜谜游戏</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-26T04:27:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-26</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-26T04:58:48.003Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-26</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Rust/">Rust</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    7 minutes read (About 1052 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="rust猜谜游戏"><a href="#rust猜谜游戏" class="headerlink" title="rust猜谜游戏"></a>rust猜谜游戏</h1><p>走完了hello world的流程之后，来做一个猜数字的游戏</p>
<h2 id="rust项目结构"><a href="#rust项目结构" class="headerlink" title="rust项目结构"></a>rust项目结构</h2><p>生成一个基本项目</p>
<pre><code class="rust">cargo new guessing_name
tree .</code></pre>
<pre><code class="rust">➜  guessing_game git:(master) ✗ tree .
.
├── Cargo.toml
└── src
    └── main.rs </code></pre>
<h3 id="Cargo-toml文件"><a href="#Cargo-toml文件" class="headerlink" title="Cargo.toml文件"></a>Cargo.toml文件</h3><pre><code class="rust">➜  guessing_game git:(master) ✗ cat Cargo.toml
[package]
name = &quot;guessing_game&quot;
version = &quot;0.1.0&quot;
authors = [&quot;alpaca &lt;1097690268@qq.com&gt;&quot;]
edition = &quot;2018&quot;

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html </code></pre>
<p>这个里面存储了该项目的信息,</p>
<ul>
<li>name表示项目名字</li>
<li>version 表示cargo 版本</li>
<li>authors 表示作者信息</li>
<li>edition 表示年份</li>
</ul>
<h3 id="main-rs文件"><a href="#main-rs文件" class="headerlink" title="main.rs文件"></a>main.rs文件</h3><p>这个文件就是你写的程序</p>
<h3 id="运行该程序"><a href="#运行该程序" class="headerlink" title="运行该程序"></a>运行该程序</h3><p>运行该程序有两种方法  一种是先编译后执行</p>
<pre><code class="bash">rustc src/main.rs </code></pre>
<p>另外一种是直接用cargo运行</p>
<pre><code class="bash">cargo run  </code></pre>
<pre><code class="rust">➜  guseeing_game git:(master) ✗ tree .
.
├── Cargo.lock
├── Cargo.toml
├── src
│   └── main.rs
└── target
    └── debug
        ├── build
        ├── deps
        │   ├── guseeing_game-0ed5a31a6f15733b
        │   ├── guseeing_game-0ed5a31a6f15733b.d
        │   └── guseeing_game-0ed5a31a6f15733b.dSYM
        │       └── Contents
        │           ├── Info.plist
        │           └── Resources
        │               └── DWARF
        │                   └── guseeing_game-0ed5a31a6f15733b
        ├── examples
        ├── guseeing_game
        ├── guseeing_game.d
        ├── guseeing_game.dSYM -&gt; deps/guseeing_game-0ed5a31a6f15733b.dSYM
        └── incremental
            └── guseeing_game-1u6x8rdyd2mj5
                ├── s-fiv8l6i4ic-1486aks-139msrfhaunjd
                │   ├── 1651w9kfz3huxj9a.o
                │   ├── 24om6g1u5n10ayrw.o
                │   ├── 2hv2ystwqwaqr9uj.o
                │   ├── 3701sophdbnzpjeb.o
                │   ├── 407p5s5dk77zb92h.o
                │   ├── 4eavspy520jyuwpr.o
                │   ├── dep-graph.bin
                │   ├── query-cache.bin
                │   └── work-products.bin
                └── s-fiv8l6i4ic-1486aks.lock</code></pre>
<p><font color='red'>你会发现这两种运行的结果所创建的文件结构是不同的</font></p>
<h2 id="获取屏幕内容并输出"><a href="#获取屏幕内容并输出" class="headerlink" title="获取屏幕内容并输出"></a>获取屏幕内容并输出</h2><pre><code class="bash">use std::io;

fn main() {
    println!(&quot;Guess the number!&quot;);

    println!(&quot;Please input your guess.&quot;);

    let mut guess = String::new();

    io::stdin().read_line(&amp;mut guess)
        .expect(&quot;Failed to read line&quot;);

    println!(&quot;You guessed: {}&quot;, guess);
}</code></pre>
<h3 id="包含语句和表达式的函数体"><a href="#包含语句和表达式的函数体" class="headerlink" title="包含语句和表达式的函数体"></a>包含语句和表达式的函数体</h3><p> 函数体有一系列的语句和一个可选的结尾的表达式构成<br> rust是基于表达式的语言<br> 用分号区分语句和表达式<br> <font color='red'>语句是执行一些操作但不返回值的指令</font><br> <font color='red'>表达式计算并产生一个值返回</font></p>
<p> 用let关键字创建变量并绑定一个值是一个语句 比如let y = 6;<br> 于是当我们使用如下</p>
<pre><code class="bash"> fn main(){
     let x = (let y =6);
 } </code></pre>
<p> let y = 6 是一个语句并不会返回一个值来使得x绑定，所以会报错 </p>
<p> let y = 6; 是一个表达式 ，返回6 函数调用是一个表达式<br> {} 是一个表达式</p>
<h3 id="具有返回值的函数"><a href="#具有返回值的函数" class="headerlink" title="具有返回值的函数"></a>具有返回值的函数</h3><p> 函数可以向调用它的代码返回值。我们并不对返回值命名，但要在箭头（-&gt;）后声明它的类型<br> 函数的返回值等同于函数体最后一个表达式的值<br> 使用 return 关键字和指定值，可从函数中提前返回；但大部分函数隐式的返回最后的表达式。这是一个有返回值的函数的例子：</p>
<pre><code class="rust"> fn five() -&gt; i32{
     5
 } 

fn main(){
    let x = five();
    println!(&quot;the value of x is {} &quot;,x )
}
</code></pre>
<p> 以上代码等同于，  {}是表达式 返回5给five()函数， let x = five();是语句，不返回值，于是let x = 5;</p>
<pre><code class="bash"> fn main(){
     let x =5 ;
 } </code></pre>
<hr>
<pre><code class="bash"> fn plus_one (x: i32) -&gt; i32{
     x + 1
 } 

 fn main(){
     let x = plus_one(5)
     println!(&quot;the value of x is :{}&quot;,x);
 }</code></pre>
<h2 id="注释"><a href="#注释" class="headerlink" title="注释"></a>注释</h2><p> rust中是用// 进行注释</p>
<h2 id="控制-逻辑操作"><a href="#控制-逻辑操作" class="headerlink" title="控制  逻辑操作"></a>控制  逻辑操作</h2><p><font color='red'>if语句</font> </p>
<pre><code class="rust"> fn main() {
    let number = 3;

    if number &lt; 5 {
        println!(&quot;condition was true&quot;);
    } else {
        println!(&quot;condition was false&quot;);
    }

    if number!=0{
        println!(&quot;nuf mber was something other than zero&quot;)
    } else if number != 2{
        println!(&quot;the number was something other than two&quot;)
    } else {
        println!(&quot;the number go&quot;)
    }
} </code></pre>
<h3 id="在let中使用if"><a href="#在let中使用if" class="headerlink" title="在let中使用if"></a>在let中使用if</h3><pre><code class="bash">fn main(){
    let 
} </code></pre>
<p><font color='red'>loop语句</font></p>
<pre><code class="rust">fn main() {
    loop {
        println!(&quot;again!&quot;);
    }
} </code></pre>
<pre><code class="rust">fn main() {
    let mut counter = 0;

    let result = loop {
        counter += 1;

        if counter == 10 {
            break counter * 2;
        }
    };

    println!(&quot;The result is {}&quot;, result);
}</code></pre>
<p><font color='red'>while条件循环</font></p>
<pre><code class="rust"> fn main() {
    let mut number = 3;

    while number != 0 {
        println!(&quot;{}!&quot;, number);

        number = number - 1;
    }

    println!(&quot;LIFTOFF!!!&quot;);
}
</code></pre>
<p><font color='red'>for 遍历循环</font></p>
<pre><code class="rust">fn main() {
    let a = [10, 20, 30, 40, 50];

    for element in a.iter() {
        println!(&quot;the value is: {}&quot;, element);
    }
} </code></pre>
<pre><code class="rust">fn main() {
    // .rev()反转 1..4 4取不到
    for number in (1..4).rev() {
        println!(&quot;{}!&quot;, number);
    }
    println!(&quot;LIFTOFF!!!&quot;);
}
</code></pre>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/26/blog_back_new/%E8%AE%BE%E5%A4%87/%E8%BD%AF%E4%BB%B6%E9%85%8D%E7%BD%AE/mac%E9%85%8D%E7%BD%AE/"><i class="fas fa-angle-double-right"></i>mac配置</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-26T04:27:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-26</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-27T09:25:48.513Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-27</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">设备</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    6 minutes read (About 839 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="mac配置"><a href="#mac配置" class="headerlink" title="mac配置"></a>mac配置</h1><h2 id="Mac-OS-中如何优雅的创建定时任务"><a href="#Mac-OS-中如何优雅的创建定时任务" class="headerlink" title="Mac OS 中如何优雅的创建定时任务"></a>Mac OS 中如何优雅的创建定时任务</h2><p>mac 可以像linux一样使用crontab来使用定时任务.另外还有一个launchctl的工具</p>
<p><font color='red'>配置文件 xxx.plist</font>  </p>
<pre><code class="bash">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt; 
&lt;plist version=&quot;1.0&quot;&gt;
    &lt;dict&gt;
        &lt;!--Plist 名称，必须唯一--&gt; 
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;cn.rayjun..plist&lt;/string&gt; 
        &lt;!-- 指定要运行的程序的名称，可以是一个程序或者是一段脚本 --&gt;   
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;/path/to/programer&lt;/string&gt; 
        &lt;/array&gt;
        &lt;!-- 执行时间的指定 --&gt; 
        &lt;key&gt;StartCalendarInterval&lt;/key&gt; 
        &lt;dict&gt; 
            &lt;!--在第几分钟会被执行 --&gt;
            &lt;key&gt;Minute&lt;/key&gt;
            &lt;integer&gt;00&lt;/integer&gt;
            &lt;!-- 在第几个小时会被执行--&gt;
            &lt;key&gt;Hour&lt;/key&gt; 
            &lt;integer&gt;22&lt;/integer&gt; 
        &lt;/dict&gt;
        &lt;!-- 运行日志 --&gt;
        &lt;key&gt;StandardOutPath&lt;/key&gt;
        &lt;string&gt;/path/to/log/x.log&lt;/string&gt;
        &lt;!-- 错误日志 --&gt;
        &lt;key&gt;StandardErrorPath&lt;/key&gt; 
        &lt;string&gt;/path/to/err/x.err&lt;/string&gt;
    &lt;/dict&gt; 
&lt;/plist&gt; </code></pre>
<p>在 Plist 中，支持两种定时任务的设置：</p>
<ul>
<li>StartInterval：定义任务多长时间（单位，秒）执行一次</li>
<li>StartCalendarInterval：这个配置类似在 crontab 中的配置，指定具体的执行日期、星期、每月、每日的各个时间点，具体参照上面的配置文件。月份和天数的配置类似。</li>
</ul>
<p><font color='red'>存放点</font><br>在 Mac 系统中，可以将需要处理的事情都写在 plist 文件中，plist 是一个 xml 格式的文件。plist 文件根据不同的需要可以放在不同的目录底下。Mac OS X 中支持放 plist 的目录如下：</p>
<ul>
<li>/Library/LaunchDaemons: 系统启动后就会执行</li>
<li>/Library/LaunchAgents: 当用户登录系统后才会执行</li>
<li>~/Library/LaunchAgents: 用户自定义的 plist</li>
<li>/System/Library/LaunchAgents: 由 Mac OS X 为用户定义的任务</li>
<li>/System/Library/LaunchDaemons: 由 Mac OS X 定义的守护进程任务</li>
</ul>
<p><font color='red'>命令行</font></p>
<pre><code class="bash">launchctl load xx.plist # 启动程序
launchctl unload xx.plist # 停止程序</code></pre>
<h2 id="解决讨厌的-DS-Store"><a href="#解决讨厌的-DS-Store" class="headerlink" title="解决讨厌的.DS_Store"></a>解决讨厌的.DS_Store</h2><p>.DS_Store (Desktop Services Store) 是一种由苹果公司的 Mac OS X 操作系统所创造的隐藏文件，目的在于存贮目录的自定义属性，例如文件们的图标位置或者是背景色的选择。相当于 Windows 下的 desktop.ini</p>
<p><font color='red'>为什么要解决？</font><br>如果不处理，每次拷贝给你同事的文件里都会包含有这个文件，或者上传网页的时候，应该把这个文件删除比较妥当，因为里面包含了一些你不一定希望别人看见的信息。（尤其是网站，通过 .DS_Store 可以知道这个目录里面所有文件的清单，很多时候这是一个不希望出现的问题。）</p>
<pre><code class="php">&lt;?php //例子
　　$filepath = &quot;images&quot;;
　　$handle = opendir($filepath);
　　while (false != ($file = readdir($handle))) {
　　    if ($file != &quot;.&quot; &amp;&amp; $file != &quot;..&quot; &amp;&amp; $file != &quot;.DS_Store&quot; &amp;&amp; $file != &quot;index.html&quot; &amp;&amp; $file != &quot;index.htm&quot; &amp;&amp; $file != &quot;index.php&quot;) {
　　        if ($output) $output .= &quot;|&quot;;
　　        $output .= &quot;$file&quot;;
　　    }
　　}
　　closedir($handle);
　　echo &quot;&amp;files=$output&amp;&quot;; //输出遍历此文件夹所有的内容
?&gt; </code></pre>
<p><font color='red'>解决</font></p>
<ul>
<li>删除当前目录的.DS_Store<pre><code class="bash">find . -name &#39;*.DS_Store&#39; -type f -delete</code></pre>
</li>
<li>删除所有目录的.DS_Store<pre><code class="bash">sudo find / -name &quot;.DS_Store&quot; -depth -exec rm {} \;</code></pre>
</li>
<li>禁止.DS_Store生成<pre><code class="bash">defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE</code></pre>
</li>
<li>恢复.DS_Store生成<pre><code class="bash">defaults delete com.apple.desktopservices DSDontWriteNetworkStores</code></pre>
git上传忽略全局文件，并且在gitconfig中引入<br>```bash<br>touch ~/.gitigonre_global<h1 id="gitignore-global"><a href="#gitignore-global" class="headerlink" title=".gitignore_global"></a>.gitignore_global</h1>####################################<br>######## OS generated files ########<br>####################################<br>.DS_Store<br>.DS_Store?</li>
</ul>
<p><em>.swp<br>._</em><br>.Spotlight-V100<br>.Trashes<br>Icon?<br>ehthumbs.db<br>Thumbs.db<br>####################################<br>############# packages #############<br>####################################<br>*.7z<br>*.dmg<br>*.gz<br>*.iso<br>*.jar<br>*.rar<br>*.tar<br>*.zip </p>
<p>#.gitconfig<br>[filter “lfs”]<br>    required = true<br>    clean = git-lfs clean %f<br>    smudge = git-lfs smudge %f<br>[user]<br>    name = bingozb<br>    email = <a href="mailto:454113692@qq.com">454113692@qq.com</a><br>[core]<br>    excludesfile = /Users/bingo/.gitignore_global</p>
<p>```</p>

        </div>
        
        
        
        
    </div>
</div>










    
<div class="card card-transparent">
    <nav class="pagination is-centered" role="navigation" aria-label="pagination">
        <div class="pagination-previous">
            <a class="is-flex-grow has-text-black-ter" href="/categories/blog-back-new/page/3/">Previous</a>
        </div>
        <div class="pagination-next is-invisible is-hidden-mobile">
            <a class="is-flex-grow has-text-black-ter" href="/categories/blog-back-new/page/5/">Next</a>
        </div>
        <ul class="pagination-list is-hidden-mobile">
            
            <li><a class="pagination-link has-text-black-ter" href="/categories/blog-back-new/">1</a></li>
            
            <li><a class="pagination-link has-text-black-ter" href="/categories/blog-back-new/page/2/">2</a></li>
            
            <li><a class="pagination-link has-text-black-ter" href="/categories/blog-back-new/page/3/">3</a></li>
            
            <li><a class="pagination-link is-current" href="/categories/blog-back-new/page/4/">4</a></li>
            
        </ul>
    </nav>
</div>
</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level" style="margin-bottom:1rem">
            <div class="level-item has-text-centered">
                <div>
                    
                        <img class="image is-96x96 has-mb-6" src="https://www.gravatar.com/avatar/e0f4032c0f2d1068ffffbaf93c0bef52?s=96" alt="Xinyu Liu">
                    
                    
                    <p class="is-size-4 is-block">
                        Xinyu Liu
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        Alpha Lxy
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>Beijing, China</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level menu-list is-mobile" style="margin-bottom:1rem">
            <div class="level-item has-text-centered is-marginless">
                <a href="/archives/">
                    <p class="heading">
                        Posts
                    </p>
                    <p class="title has-text-weight-normal">
                        40
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/categories/">
                    <p class="heading">
                        Categories
                    </p>
                    <p class="title has-text-weight-normal">
                        13
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/tags/">
                    <p class="heading">
                        Tags
                    </p>
                    <p class="title has-text-weight-normal">
                        0
                    </p>
                </a>
            </div>
        </nav>
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://www.github.com/AlphaLxy" target="_blank">
                <i class="fab fa-github"></i>&nbsp;&nbsp;Follow</a>
        </div>
        
        
    </div>
</div>

    
        

    
        


    
        

    
        <div class="card widget is-hidden-mobile">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            Archives
        </h3>
        <ul class="menu-list">
        
        <li>
            <a class="level is-marginless" href="/archives/2020/01/">
                <span class="level-start">
                    <span class="level-item">January 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">8</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2019/12/">
                <span class="level-start">
                    <span class="level-item">December 2019</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">32</span>
                </span>
            </a>
        </li>
        
        </ul>
        </div>
    </div>
</div>

    
    
        <div class="column-right-shadow is-hidden-widescreen ">
        
            
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="keepalive+lvs 四层负载均衡">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T05:06:09.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="has-link-black-ter is-size-6">keepalive+lvs 四层负载均衡</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="iptables、firewall 防火墙">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T04:03:16.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="has-link-black-ter is-size-6">iptables、firewall 防火墙</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="netstat">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T03:51:48.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="has-link-black-ter is-size-6">netstat</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="网络部署需求分析">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-04T02:22:09.000Z">2020-01-04</time></div>
                    <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="has-link-black-ter is-size-6">网络部署需求分析</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="httpd服务">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-03T09:18:50.000Z">2020-01-03</time></div>
                    <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="has-link-black-ter is-size-6">httpd服务</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>

        
            
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/blog-back-new/">
            <span class="level-start">
                <span class="level-item">blog_back_new</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">39</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/blog-back-new/C%E8%AF%AD%E8%A8%80/">
            <span class="level-start">
                <span class="level-item">C语言</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Python/">
            <span class="level-start">
                <span class="level-item">Python</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Rust/">
            <span class="level-start">
                <span class="level-item">Rust</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/ansible/">
            <span class="level-start">
                <span class="level-item">ansible</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/django/">
            <span class="level-start">
                <span class="level-item">django</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">8</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/linux/">
            <span class="level-start">
                <span class="level-item">linux</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/mysql/">
            <span class="level-start">
                <span class="level-item">mysql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%89%A9%E5%B1%95/">
            <span class="level-start">
                <span class="level-item">扩展</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
            <span class="level-start">
                <span class="level-item">数据结构</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">
            <span class="level-start">
                <span class="level-item">网络</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">
            <span class="level-start">
                <span class="level-item">设备</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a></li></ul></li>
            </ul>
        </div>
    </div>
</div>
        
        </div>
    
</div>

                




<div class="column is-4-tablet is-4-desktop is-3-widescreen is-hidden-touch is-hidden-desktop-only has-order-3 column-right ">
    
        
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="keepalive+lvs 四层负载均衡">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T05:06:09.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="has-link-black-ter is-size-6">keepalive+lvs 四层负载均衡</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="iptables、firewall 防火墙">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T04:03:16.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="has-link-black-ter is-size-6">iptables、firewall 防火墙</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="netstat">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T03:51:48.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="has-link-black-ter is-size-6">netstat</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="网络部署需求分析">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-04T02:22:09.000Z">2020-01-04</time></div>
                    <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="has-link-black-ter is-size-6">网络部署需求分析</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="httpd服务">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-03T09:18:50.000Z">2020-01-03</time></div>
                    <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="has-link-black-ter is-size-6">httpd服务</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>

    
        
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/blog-back-new/">
            <span class="level-start">
                <span class="level-item">blog_back_new</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">39</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/blog-back-new/C%E8%AF%AD%E8%A8%80/">
            <span class="level-start">
                <span class="level-item">C语言</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Python/">
            <span class="level-start">
                <span class="level-item">Python</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Rust/">
            <span class="level-start">
                <span class="level-item">Rust</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/ansible/">
            <span class="level-start">
                <span class="level-item">ansible</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/django/">
            <span class="level-start">
                <span class="level-item">django</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">8</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/linux/">
            <span class="level-start">
                <span class="level-item">linux</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/mysql/">
            <span class="level-start">
                <span class="level-item">mysql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%89%A9%E5%B1%95/">
            <span class="level-start">
                <span class="level-item">扩展</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
            <span class="level-start">
                <span class="level-item">数据结构</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">
            <span class="level-start">
                <span class="level-item">网络</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">
            <span class="level-start">
                <span class="level-item">设备</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a></li></ul></li>
            </ul>
        </div>
    </div>
</div>
    
    
</div>

            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container">
        <div class="level">
            <div class="level-start has-text-centered-mobile">
                <a class="footer-logo is-block has-mb-6" href="/">
                
                    <img src="/images/logo.svg" alt="noback" height="28">
                
                </a>
                <p class="is-size-7">
                &copy; 2020 Alpaca&nbsp;
                Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> & <a
                        href="http://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
                
                <br>
                <span id="busuanzi_container_site_uv">
                Visited by <span id="busuanzi_value_site_uv">0</span> users
                </span>
                
                </p>
            </div>
            <div class="level-end">
            
                <div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">
                
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
                        
                        <i class="fab fa-creative-commons"></i>&nbsp;<i class="fab fa-creative-commons-by"></i>&nbsp;<i class="fab fa-creative-commons-nc"></i>&nbsp;<i class="fab fa-creative-commons-sa"></i>&nbsp;
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>&nbsp;
                        
                    </a>
                </p>
                
                </div>
            
            </div>
        </div>
    </div>
</footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("en");</script>


    
    
    
    <script src="/js/animation.js"></script>
    

    
    
    
    <script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
    <script src="/js/gallery.js" defer></script>
    

    
    

<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


    
    
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>

    
    

<a id="back-to-top" title="Back to Top" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/js/back-to-top.js" defer></script>


    
    

    
    
    
    

    
    
    
    
    
    <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>
    <script src="/js/clipboard.js" defer></script>
    

    
    
    

    


<script src="/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="Type something..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            CONTENT_URL: '/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/js/insight.js" defer></script>
<link rel="stylesheet" href="/css/search.css">
<link rel="stylesheet" href="/css/insight.css">
    
</body>
</html>